/**
 * Default long-poll operation. Bind request and send buffer or wait
 * 
 */
var Keepalive = function(app) {
	app.all('/keepalive', function(req, res) {
		var session = req.session || {};
		
		// Only connect to server after a command/keepalive request
		session.start();
		
		if (session.clientBuffer.length > 0) {
			debug.log("	Buffer --> " + JSON.stringify(session.clientBuffer) + " --> Client");
			res.send(session.clientBuffer);
			session.clientBuffer = [];
			session.releaseClient();
		}
	});
};

exports.create = Keepalive;
